package com.black.cat.jvm.instructions.loads.xaload;


import com.black.cat.jvm.instructions.base.InstructionNoOperands;
import com.black.cat.jvm.rtda.Frame;
import com.black.cat.jvm.rtda.JObject;
import com.black.cat.jvm.rtda.OperandStack;


public class AALOAD extends InstructionNoOperands {

    @Override
    public void execute(Frame frame) {
        OperandStack stack = frame.operandStack();
        int idx = stack.popInt();
        JObject arrRef = stack.popRef();

        checkNotNull(arrRef);
        Object[] refs = arrRef.refs();
        checkIndex(refs.length, idx);
        stack.pushRef((JObject)refs[idx]);
    }

}
